<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<jsp:include page="../common/adminContentHead.jsp" />
<title>课程设计管理系统</title>
</head>
<body>
	<!-- begin搜索 -->
	<div class="well well-sm" id="searchIntro">
		<form id="searchForm" class="form-inline">
			<div class="row">
				<div class="form-group  col-md-12">
					<div class="input-group">
						<span class="input-group-addon">题目</span>
						<input class="form-control" name="name">
					</div>
					
					<div class="input-group" style="margin-left: 20px;">
						<button type="button" class="btn btn-success" onclick="loadPaging(1)">搜索</button>
						<input type="reset" id="formRest" style="display: none;">
						<button type="button" class="btn btn-success" onclick="resetIntro(1)" style="margin-left: 5px;">重置</button>
					</div>
				</div>
			</div>
		</form>
	</div>
	<div class="row">
		<div class="col-md-12" id="userList">
			<div class="panel panel-default">
				<div class="panel-heading" style="padding: 5px 15px;">
				</div>
				<div class="panel-body hfit" style="overflow-x: auto;">
					<input type="hidden" id="currentUserId">
					<!-- Table -->
				  	<table class="table table-bordered table-hover"  id="table_users_fqj">
					   <thead>
					      <tr>
					      	 <th style="width: 30px;"><input type="checkbox"></th>
					         <th field="taskName" render="taskName">课题名称</th>
					         <th field="teacherName"  render="teacherName">指导老师</th>
					         <th field="groupName">小组名</th>
					         <th field="score">分数</th>
					         <th field="finishDate">截止日期</th>
					      </tr>
					   </thead>
					</table>
					<div id="table_Paging_fqj"></div>
				</div>
			</div>
		</div>
	</div>
 	<div id=showMember class="panel panel-default" style="padding: 10px 30px;border: none;display: none;">
		<div class="form-group" >
			<div class="form-group col-md-14">
				<input type="hidden" id="toid">
			  	<textarea  class="form-control" placeholder="内容" id="content" ></textarea>
			</div>
			<div class="form-group col-md-14">
			  	<button type="button" class="btn btn-default form-control repy" >留言</button>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/system/bootstrapTable.js?v=<%=getServletContext().getAttribute("version") %>"></script>
	<script type="text/javascript">
		/* 初始化 start */
		$(function() {
			var divheight = $(window).height();//初始化修改div的高度
			divheight = divheight - 125;
			$(".hfit").css({
				height : divheight
			});
			loadPaging(1);
		});
		 
		function loadUsers(pageNum){
			var url=rootpath+"/student/topic/getlist.shtml";
			var offSet=(pageNum-1)*10;
			var searchData=$("#searchForm").getFormData();
			searchData.offSet=offSet;
			searchData.pageSize=10;
			$.post(url,searchData,function(rows){
				$("#table_users_fqj").table(rows);
				//初始化分页插件
			});
		}
		function loadPaging(pageNum){
			var url=rootpath+"/student/topic/getlist.shtml";
			var offSet=(pageNum-1)*10;
			var searchData=$("#searchForm").getFormData();
			searchData.offSet=offSet;
			searchData.pageSize=10;
			$.post(url,searchData,function(data){
				var rows=data.items;
				var count=data.rowsCount;
				$("#table_users_fqj").table(rows);
				//初始化分页插件
				$("#table_Paging_fqj").tablePaging(1,10,count,"loadUsers");
			});
		}
		
		/*重置*/
		function resetIntro(){
			$("#searchForm").reset();
			loadPaging(1);
		}
		
		 
		/*按钮渲染*/
		function taskName(e){
			var row=e.row;
			var url=rootpath+"/prog/myProg.shtml?gid="+row.groupId;
			var btns = new Array();
			btns.push('<a href="'+url+'">'+row.taskName+'</a>');
			return btns.join("&nbsp;&nbsp;");;
		}
		
		function teacherName(e){
			var row=e.row;
			var btns = new Array();
			btns.push('<a href="javascript:(0);" onclick="LeavingMessage('+row.teacherId+')">'+row.teacherName+'</a>');
			return btns.join("&nbsp;&nbsp;");;
		}
		
		
		function LeavingMessage(toId){
			$("#toid").val(toId);
			layer.open({
				 type : 1,
				title : '留言',
				 area : [ '580px', '500px' ],
			  content : $('#showMember'),
			  end:function(){
				  loadPaging(1);
			  }
			});
		}
		
		$('.repy').click(function(){
			var toid=$("#toid").val();
			var content=$("#content").val();
			var url = rootpath + "/mess/save.shtml";
			$.post(url,{"content":content,"to":toid},function(data) {
				if(data.status){
					$("#content").val('')
					layer.msg('留言成功');
					layer.closeAll();
				}
			});
		})
	</script>
	
</body>
</html>
